<?php

class UserDirectory
{
  var $template_name;
  var $path;
  
  function prepare($user_dir,$template_dir,$template_name)
  {
    $this->template_name = $template_name;
    $this->path = $user_dir;
    
    // Delete Files in Directory
    $dir_listing = dir($user_dir);
    while(($dir_entry = $dir_listing->read()) !== false)
    {
      if (($dir_entry != ".") && ($dir_entry != ".."))
      {
        if (is_file($user_dir."/".$dir_entry))
        {
          unlink($user_dir."/".$dir_entry);
        }
      }
    }

    // Copy Files
    $dir_listing = dir($template_dir);
    while(($dir_entry = $dir_listing->read()) !== false)
    {
      if (($dir_entry != ".") && ($dir_entry != ".."))
      {
        if (is_file($template_dir."/".$dir_entry))
        {
          copy($template_dir."/".$dir_entry, $user_dir."/".$dir_entry);
        }
      }
    }
  }
  
  function getPath()
  {
    return $this->path;
  }
  
  function getTemplateName()
  {
    return $this->template_name;
  }
  
  
  
}

?>